/*
 * @Author: hrg
 * @Date: 2024-01-23 09:38:25
 * @LastEditTime: 2024-01-23 11:17:28
 * @FilePath: \study_go\study06_gin\gin_demo03\main.go
 * @Description:API参数
 */
package main

import (
	"net/http"
	"strings"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()

	// :user 是一个参数，  *action是一个匹配多段的通配符
	r.GET("user/:name/*action", func(c *gin.Context) {
		name := c.Param("name")
		action := c.Param("action")

		// 截取/
		action = strings.Trim(action, "/")
		c.String(http.StatusOK, name+" is "+action)
	})

	r.Run(":8000")

}
